package pe.com.mowa.siscobsms.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pe.com.mowa.siscobsms.datos.conPersona;
import pe.com.mowa.siscobsms.bean.*;

/**
 * Servlet implementation class setPersona
 */
public class setPersona extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public setPersona() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stu
		
     	    PrintWriter out = response.getWriter();
     	    
     	    String nombre = request.getParameter("txtNombre");
     	    String apePat = request.getParameter("txtapePat");
     	    String apeMat = request.getParameter("txtapeMat");
     	    String telefono1 = request.getParameter("txtTelefono1");
     	    String telefono2 = request.getParameter("txtTelefono2");
     	    String direccion = request.getParameter("txtDireccion");
     	    String idlocal = request.getParameter("local");
		    out.println("<script>");
		    out.println("alert('registro correcto ');");
		    out.println("</script>");
		    
		    conPersona cp = new conPersona();
		    
		    persona per = new persona();
		    per.setNombre(nombre);
		    per.setApePat(apePat);
		    per.setApeMat(apeMat);
		    per.setTel1(telefono1);
		    per.setTel2(telefono2);
		    per.setDireccion(direccion);  
		    
		    
		    
		    try {
				cp.setPersona(per);
				response.sendRedirect("regPersona.jsp");
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		    out.close();
		    
   	}

}
